package routers

import (
	"github.com/gin-gonic/gin"
	"yak.admin/src/middleware"
	devicerouter "yak.admin/src/module/api/device"
	drugrouter "yak.admin/src/module/api/drug"
	userrouter "yak.admin/src/module/api/user"
	apictrl "yak.admin/src/module/api/user/controller"
)

func ApiRouter(router *gin.Engine) *gin.Engine {
	group := router.Group("/api")
	group.Use(middleware.TokenAuth())
	{
		drugrouter.Routers(group)
		userrouter.Routers(group)
		devicerouter.Routers(group)
	}
	router.GET("/api/403", func(ctx *gin.Context) {
		middleware.ResultRefuse(ctx, "禁止访问", nil)
	})
	router.POST("/api/register", apictrl.Register)
	router.POST("/api/login", apictrl.Login)
	router.POST("/api/reset-password", apictrl.ResetPassword)
	router.GET("/api/send-sms", apictrl.SendSmsByGuest)
	return router
}
